package com.zlf.mapper;

import com.zlf.po.Business;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BusinessMapper {
    @Select("select * from business where orderTypeId=#{orderTypeId} order by businessId")
    public List<Business> listBusinessByOrderTypeId(Integer orderTypeId);

    @Select("select * from business where businessId=#{businessId}")
    public Business getBusinessById(Integer businessId);
    @Select("select * from business order by businessId")
    List<Business> listBusiness();

    @Select("SELECT * FROM business WHERE businessName LIKE CONCAT('%', #{key}, '%') order by businessId")
    List<Business> selectBusiness(String key);

    @Insert("INSERT into business values (#{businessId},#{businessName},#{businessAddress},#{businessExplain},#{businessImg},#{orderTypeId},#{starPrice},#{deliveryPrice},null,#{pass})")
    int saveBusiness(Business pram);

    @Update("update business set businessName=#{businessName} , businessAddress=#{businessAddress} , businessExplain=#{businessExplain} " +
            " , starPrice=#{starPrice} , deliveryPrice=#{deliveryPrice} where businessId=#{businessId}")
    int updateBusiness(Business business);

}

